<template>
  <div>
    <table border="1">
      <caption>
        欢迎光临 vue开发的收银系统 水果店
      </caption>
      <tbody>
        <tr>
          <th>苹果10$ 1斤 折扣:8</th>
        </tr>
        <tr>
          <td>
            请输入你购买的斤数
            <input type="number" name="" id="" v-model="num" />
          </td>
        </tr>
        <tr>
          <td><button @click="btn">结账买单</button></td>
        </tr>
        <tr>
          <td>
            结账单:总价 {{ zongJia }}$元 折扣价格 {{ zeKou }}$元 省了{{
              sheng
            }}$元
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script>
export default {
  data() {
    return {
      num: 0,
      zongJia: "",
      zeKou: "",
      sheng: "",
    };
  },
  methods: {
    btn() {
      this.zongJia = this.num * 10;
      this.zeKou = this.num * 10 * 0.8;
      this.sheng = this.zongJia - this.zeKou;
    },
  },
};
</script>

<style lang="less">
table {
  width: 400px;
  margin: 0 auto;
  text-align: center;
}
</style>>
</style>